#include <iostream>
#include <fstream>
#include <vector>
#include <cassert>
using namespace std;

typedef int keytype;

void bubble(vector<keytype> &keys)
{
  int i, j;
  keytype t;
  bool flag = true;

  for (i = keys.size()-1; i > 0 && flag; i--){
    flag = false;
    for (j = 0; j < i; j++)
      if (keys[j] > keys[j+1]){
	flag = true;
	t = keys[j];
	keys[j] = keys[j+1];
	keys[j+1] = t;
      }
  }
}

void print(vector<keytype> &keys)
{
  for (auto it = keys.begin(); it != keys.end(); it++)
    cout << *it << "\t";
  cout << endl;
}

int main()
{
  ifstream in("sort.txt");
  vector<keytype> keys;
  keytype k;

  assert(in);
  while (in >> k)
    keys.push_back(k);

  bubble(keys);
  print(keys);
  in.close();

  return 0;
}
